package com.zhiyou100.action;

import com.zhiyou100.entity.Attendance;
import com.zhiyou100.entity.ResponseVO;
import com.zhiyou100.mapper.AttendanceMapper;
import com.zhiyou100.service.AttendanceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Controller
@RequestMapping("/attendance")
public class AttendanceController {
      @Autowired
      private AttendanceService attendanceService;

      @ResponseBody
      @GetMapping("/getOne/{aid}")
      public ResponseVO<Attendance>  getOneMethod(@PathVariable("aid") Integer aid){
          return new ResponseVO<>(200,"获取成功！",attendanceService.getOneById(aid));
      }
      @ResponseBody
      @GetMapping("/getAll")
      public ResponseVO<List<Attendance>>  getAllMethod(){
            return new ResponseVO<>(200,"获取成功！",attendanceService.getAll());
      }

      @ResponseBody
      @PostMapping("/addOne")
      public ResponseVO<Integer>  addOneMethod(Attendance a){
            return new ResponseVO<>(200,"添加成功！",attendanceService.insertOne(a));
      }

      @ResponseBody
      @PutMapping("/updateOne")
      public ResponseVO<Integer>  updateOneMethod(Attendance a){
            return new ResponseVO<>(200,"修改成功！",attendanceService.updateOneById(a));
      }
      @ResponseBody
      @DeleteMapping("/deleteOne/{aid}")
      public ResponseVO<Integer>  deleteOneMethod(@PathVariable("aid") Integer aid){
            return new ResponseVO<>(200,"删除成功！",attendanceService.deleteOneById(aid));
      }

}
